local skel = fk.CreateSkill {
  name = "emo__duya",
  tags = {Skill.Compulsory},
}

Fk:loadTranslationTable{
  ["emo__duya"] = "渡鸦",
  [":emo__duya"] = "锁定技，你每回合首次失去♠牌后，获得一张<a href=':eagle'>【鹰】</a>。",

  ["#emo__yuanzhao"] = "怨沼：可以令任意名角色随机将一张牌交给其下家",
}

skel:addEffect(fk.AfterCardsMove, {
  anim_type = "drawcard",
  can_trigger = function (self, event, target, player, data)
    if player:hasSkill(skel.name) and player:getMark("emo__duya-turn") == 0 then
      local first = player.room.logic:getEventsOfScope(GameEvent.MoveCards, 1, function(e)
        for _, move in ipairs(e.data) do
          if move.from == player then
            for _, info in ipairs(move.moveInfo) do
              if info.fromArea == Card.PlayerHand or info.fromArea == Card.PlayerEquip then
                if Fk:getCardById(info.cardId).suit == Card.Spade then
                  return true
                end
              end
            end
          end
        end
      end, Player.HistoryTurn)[1]
      if first and first.data == data then
        return true
      end
    end
  end,
  on_use = function (self, event, target, player)
    local room = player.room
    room:setPlayerMark(player, "emo__duya-turn", 1)
    if Fk.all_card_types["eagle"] == nil then return end
    local card = room:printCard("eagle", Card.Diamond, 4)
    room:obtainCard(player, card, true, fk.ReasonJustMove, player, skel.name)
  end,
})

return skel
